﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cn.Edwon.Web.Support;
using Cn.Cellula.Client;
using Cn.Edwon.Web.Validation;
using Cn.Edwon.Web;

namespace Cn.Cellula.Website.Admin.Tools {
    public partial class SendMail : PageSupport {
        protected void Page_Load(object sender, EventArgs e) {
            if (!Page.IsPostBack) {
                InitForm();
            }
        }

        private void InitForm() {
            this.txt_From.Text = SiteConfig.Smtp.SmtpFrom;
        }

        protected void btn_SendMail_Click(object sender, EventArgs e) {
            bool bk = QuickValidator.Execute(Request, this.txt_SendTo.Parent);
            if (!bk) {
                SiteInfo.Send(Page, TxtDef.ERROR, QuickValidator.Message);
                return;
            }
            try {
                MailBiz.SendMail(this.txt_Title.Text, this.txt_Content.Text, this.txt_SendTo.Text, this.txt_From.Text);
                SiteInfo.Send(Page, TxtDef.SUCCEED, "发送成功");
            } catch (Exception ex) {
                SiteInfo.Send(Page, TxtDef.ERROR, ex.Message);
            }
        }
    }
}
